package com.gaojiawei.multiThread11_ThreadPoolJDk;

import java.util.concurrent.Executor;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * the number of FixedThreadExcutor is fixed
 */
public class L01_FixedThreadExcutor {
    public static void main(String[] args) {
        //create thread fixed thread pool
        ExecutorService fixedThreadPool = Executors.newFixedThreadPool(2);

        fixedThreadPool.execute(()->{
            System.out.println("the first task:"+Thread.currentThread().getName()+System.currentTimeMillis());
            try {
                Thread.sleep(5000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        });

        fixedThreadPool.execute(()->{
            System.out.println("the second task:"+Thread.currentThread().getName()+System.currentTimeMillis());
            try {
                Thread.sleep(5000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        });

        //the third task hava above five second delay
        fixedThreadPool.execute(()->{
            System.out.println("the third task:"+Thread.currentThread().getName()+System.currentTimeMillis());
            try {
                Thread.sleep(5000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        });




    }
}
